package obj;

import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

import util.Settings;

/**
 * Enemy class.
 * @author VincentLy
 */
public class Enemy extends Sprite{
	
	private float maxhp = 10;
	private float hp;
	private Animation anim;
	
	public Enemy(float x,float y,int d,Animation a) throws SlickException{
		super(x+30,y,d,Settings.enemy1);
		hp = 10;
		maxhp = 10;
		anim = a.copy();
	}

	public Animation anim(){return anim;}
	
	public void setMaxHP(float h){maxhp = h;}
	/**
	 * @return hp
	 * @author VincentLy
	 */
	public float hp(){return hp;}
	
	/**
	 * @param h - hp
	 * @author VincentLy
	 */
	public void setHP(float h){hp = h;}
	
	/**
	 * Handles the enemy update.
	 * @author VincentLy
	 */
	public void update(){super.update();}
	
	/**
	 * Draws the enemy.
	 * @author VincentLy
	 */
	public void draw(Graphics g){
		anim.draw(left()-15,top()-30);
		g.setColor(Color.white);
		g.fillRect(left(),top()-10,width()*hp/maxhp,5);
	}
}